<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="quo" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="amendmentContractSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/psi/supplychainmana/ContractDetails?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 修改采购合同 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="合同编号" prop="quo_num">
                  <el-input v-model="quo.quo_num" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主题" prop="quo_theme">
                  <el-input v-model="quo.quo_theme" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="供应商" prop="quo_client">
                  {{quo.quo_client}}
                  <el-button @click="popSelectionSuppliers('quo_client','quo_client')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="联系人" prop="quo_contact">
                  {{quo.quo_contact}}
                  <el-button @click="popChooseContacts('quo_contact','quo_contact')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="地址" prop="quo_address">
                  <el-input type="textarea" v-model="quo.quo_address" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="签订日期" prop="quo_pacttime">
                  <el-date-picker v-model="quo.quo_pacttime" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="失效日期 " prop="quo_faildate">
                  <el-date-picker v-model="quo.quo_faildate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="内部备注" prop="quo_insides">
                  <el-input type="textarea" v-model="quo.quo_insides" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 列表条目 </span>
          </div>
          <el-table :data="pum">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_producenum('&CMIDpronum_id='+scope.row.pronum_id+'')">移除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="产品条形码" prop="product_barcode">
            </el-table-column>
            <el-table-column label="产品名称" prop="pronum_prodece">
            </el-table-column>
            <el-table-column label="供应商" prop="client_name">
            </el-table-column>
            <el-table-column label="产品型号" prop="product_model">
            </el-table-column>
            <el-table-column label="产品规格" prop="product_norm">
            </el-table-column>
            <el-table-column label="简要描述" prop="product_des">
            </el-table-column>
            <el-table-column label="补充" prop="pronum_remark">
            </el-table-column>
            <el-table-column label="数量" prop="pronum_no">
            </el-table-column>
            <el-table-column label="数量单位" prop="pronum_nuit">
            </el-table-column>
            <el-table-column label="单价" prop="pronum_price">
            </el-table-column>
            <el-table-column label="发货时间" prop="">
            </el-table-column>
            <el-table-column label="总价" prop="total_prices">
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('231DF3E37F1A4FF2932D223D957877CB?&category_id=&cpopup=reload'+vueparams+'')" type='primary' size="mini">选择产品</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 甲乙双方责任 </span>
          </div>
          <el-table :data="s_duty">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_duty('&CMIDduty_id='+scope.row.duty_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="duty_name">
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('60ADC0B2DF1B4DB59C06D66CA8465989?&cpopup=reload'+vueparams+'')" type='primary' size="mini">选择责任</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 付款方式 </span>
          </div>
          <el-table :data="s_pay">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_pay('&CMIDpay_id='+scope.row.pay_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="首次付款" prop="pay_first">
            </el-table-column>
            <el-table-column label="二次付款" prop="pay_sec">
            </el-table-column>
            <el-table-column label="尾付款" prop="pay_end">
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('8F5E7752B87C45D38CB57E380D2019E5?&cpopup=reload'+vueparams+'')" type='primary' size="mini">建立付款方式</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 付款账号 </span>
          </div>
          <el-table :data="s_bank">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_bank('&CMIDbank_id='+scope.row.bank_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage(''+vueparams+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="类型" prop="bank_type">
            </el-table-column>
            <el-table-column label="银行名称" prop="bank_tname">
            </el-table-column>
            <el-table-column label="开户姓名" prop="bank_tname">
            </el-table-column>
            <el-table-column label="银行账号" prop="bank_account">
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('F8165C57842F4EEDAE2192B53FD7AA91?&cpopup=reload'+vueparams+'')" type='primary' size="mini">选择付款账号</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 违约责任 </span>
          </div>
          <el-table :data="s_breakduty">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_breakduty('&CMIDbreakduty_id='+scope.row.breakduty_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="break_name">
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('A0440A50574F477B89377D31B2DB6F7F?&cpopup=reload'+vueparams+'')" type='primary' size="mini">选择违约责任</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 其他要求 </span>
          </div>
          <el-table :data="s_demand">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_demand('&CMIDdemand_id='+scope.row.demand_id+'')">移除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="demand_name">
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('A4A6ADB0CE67437BBA0EE77DD5E44908?&cpopup=reload'+vueparams+'')" type='primary' size="mini">选择其他要求</el-button>
          <div>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 备注 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="内部备注" prop="quo_insides">
                  <el-input type="textarea" v-model="quo.quo_insides" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'采购合同'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="SelectionSuppliersVisible" append-to-body>
      <SelectionSuppliers v-if="SelectionSuppliersVisible" ref="SelectionSuppliers" :popparams="popparams"> </SelectionSuppliers>
    </el-dialog>
    <el-dialog :visible.sync="ChooseContactsVisible" append-to-body>
      <ChooseContacts v-if="ChooseContactsVisible" ref="ChooseContacts" :popparams="popparams"> </ChooseContacts>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectionSuppliers from "@/views/psi/supplychainmana/SelectionSuppliers";
  import ChooseContacts from "@/views/psi/supplychainmana/ChooseContacts";
  export default {
    name: 'AmendmentContract',
    components: {
      SelectionSuppliers,
      ChooseContacts,
    },
    props: ['popparams'],
    data() {
      return {
        SelectionSuppliersVisible: false,
        SelectionSuppliersValue: null,
        SelectionSuppliersDesc: null,
        ChooseContactsVisible: false,
        ChooseContactsValue: null,
        ChooseContactsDesc: null,
        vueparams: this.getVUEParams(""),
        quo: {
          quo_num: null,
          quo_theme: null,
          quo_client: null,
          quo_contact: null,
          quo_address: null,
          quo_pacttime: null,
          quo_faildate: null,
          quo_insides: null,
        },
        pum: [],
        s_duty: [],
        s_pay: [],
        s_bank: [],
        s_breakduty: [],
        s_demand: [],
        loading: false,
        Container: null,
        rules: {
          quo_num: [{
            required: true,
            message: "合同编号不能为空",
            trigger: 'blur',
          }],
          quo_theme: [{
            required: true,
            message: "主题不能为空",
            trigger: 'blur',
          }],
          quo_client: [{
            required: true,
            message: "供应商不能为空",
            trigger: 'change',
          }],
          quo_faildate: [{
            required: true,
            message: "失效日期 不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "821959E4C08E497BA9C4B10D9571712F",
        name: "采购任务右菜单",
        selected: "采购合同"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/amendmentContract?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      amendmentContractSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/amendmentContractSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/psi/supplychainmana/ContractDetails/contractDetails?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      d_producenum(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_producenum?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_duty(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_duty?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_pay(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_pay?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_bank(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_bank?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_breakduty(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_breakduty?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_demand(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_demand?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      c_pirce(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/c_pirce?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popSelectionSuppliers(desc, value) {
        this.SelectionSuppliersVisible = true;
        this.SelectionSuppliersDesc = desc;
        this.SelectionSuppliersValue = value;
      },
      closeSelectionSuppliers(value, desc) {
        this.SelectionSuppliersVisible = false;
        this.$set(this.quo, this.SelectionSuppliersDesc, desc);
        this.$set(this.quo, this.SelectionSuppliersValue, value);
      },
      popChooseContacts(desc, value) {
        this.ChooseContactsVisible = true;
        this.ChooseContactsDesc = desc;
        this.ChooseContactsValue = value;
      },
      closeChooseContacts(value, desc) {
        this.ChooseContactsVisible = false;
        this.$set(this.quo, this.ChooseContactsDesc, desc);
        this.$set(this.quo, this.ChooseContactsValue, value);
      },
    },
  }
</script>
